﻿// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.DependencyInjection;
using ConsoleApp2;
using ConsoleApp2.Event;

Console.WriteLine("Hello, World!");

var serviceProvider = new ServiceCollection()
                .AddSingleton<IEventBus, EventBus>()
                .AddTransient<IDoSomethingService, DoSomethingService>()
                .BuildServiceProvider();

//var someService = serviceProvider.GetRequiredService<DoSomethingService>();

var eventBus = serviceProvider.GetService<IEventBus>();
if (eventBus != null)
{
    //订阅
    //eventBus.Subscribe<DoSomethingEvent, DoSomethingEventHandler>();

    //var someService = serviceProvider.GetRequiredService<DoSomethingService>();

    //await someService.DoSomethingAsync("test@example.com", "TestEmail", "Hello,thisisatestemail.");
}